package com.kc.web.controller.business;

import com.kc.business.domain.BizComment;
import com.kc.business.service.IBizCommentService;
import com.kc.common.annotation.Log;
import com.kc.common.core.controller.BaseController;
import com.kc.common.core.domain.AjaxResult;
import com.kc.common.core.page.TableDataInfo;
import com.kc.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 评论controller
 */
@RestController
@RequestMapping("/business/comment")
public class BizCommentController extends BaseController {
    @Autowired
    private IBizCommentService commentService;
    /**
     * 评论列表
     * @param bizComment
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:comment:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizComment bizComment) {
        startPage();
        List<BizComment> list = commentService.getList(bizComment);
        return getDataTable(list);
    }
    /**
     * 评论删除
     * @param id
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:comment:remove')")
    @Log(title = "用户评论管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Integer id){
        BizComment bizComment = new BizComment();
        bizComment.setId(id);
        bizComment.setStatus(-1);
        bizComment.setIsDeleted(1);
        return toAjax(commentService.remove(bizComment));
    }
}
